package com.hy;

import java.util.Scanner;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:
 * User:Mr.Du
 * Date:2024/7/28
 * Time:15:47
 */
public class RemoveDuplicates {
    public int removeDuplicates(int[] nums) {
        int s = 0;
        for(int x : nums){
            if(s < 2 || nums[s - 2] != x) nums[s++] = x;
        }
        return s;
    }

    public static void main(String[] args) {
        RemoveDuplicates removeDuplicates = new RemoveDuplicates();
//        removeDuplicates.removeDuplicates(new int[]{1,1,1,1,1,1,2,2,2,2,2,2,3,4,4,5,6});
        test2();
    }

    public static void test2(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), q = sc.nextInt();
        String s = sc.next();
        StringBuffer sb = new StringBuffer(s);
        StringBuffer t = new StringBuffer(s);
        int[] nums = new int[n];
        for(int i = 0;i<n;i++) nums[i] = sc.nextInt();
        for(int i = 0;i < n;i++){
            if(i % 2 == 1){
                sb.deleteCharAt(sb.length() - 1);
                t.append(sb);
            }else{
                sb.deleteCharAt(0);
                t.append(sb);
            }
            System.out.println(t.charAt(nums[i]-1));
            if(sb.length() == 0) break;
        }
    }

}
